<template>
  <div>
      <form class="mui-input-group">
                     <div class="mui-input-row">
						<label>会员类型:</label>
						<select id="method" v-model="id">
							<option :value="vip.v_id" v-for="vip in viplist" :key="vip.v_id" >{{vip.v_name}}</option>
						</select>
					</div>
					<div class="mui-input-row" style="height:55px">
						<label>会员详情:</label>
						<span>{{content}}</span>
					</div>
					<div class="mui-input-row ">
						<label>折扣:</label>
						<span>{{discount}}</span>
					</div>
					<div class="mui-button-row">
						<button type="button" class="mui-btn mui-btn-primary" @click="addvip">确认</button>
					</div>
	</form>
  </div>
</template>

<script>
import {Toast} from 'mint-ui'
export default {
   data(){
       return{
           uid:this.$route.params.uid,
           viplist:[],
           id:this.$route.params.vid,
           content:this.$route.params.content,
           discount:this.$route.params.discount,
          
       }
   },
   methods:{
        getvip(){     
            this.$ajax({
                url:"before/vipkind",
                method:"get"
            }).then(resp=>{
                this.viplist = resp.data.message;
         })
       },
        addvip(){
            let person={
              
                "u_v_id":this.id,
                "u_id":this.uid
            }
              console.log(this.id);
              console.log(this.uid);
            this.$ajax({
			   url:'/before/addvip',
			   method:'put',
			   data:person
		   }).then(resp=>{
			   Toast("会员开通成功")
               this.$router.push("/user/userInfo")
		   })
        }
   },
   created(){
       this.getvip()
   },
   watch:{
       "id":function(val){
        this.viplist.some(item=>{
            if(item.v_id==val){
                this.discount=item.v_discount
                this.content=item.v_content
            }
        })
       }
   }
}
</script>

<style scoped>
 span{
     display: block;
     margin-top: 11px;
     
 }
</style>